define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {


	httpService.post(app.urls.grade_selectCenterGrade,{"fk_unit":"self"},function(data){
			if("0000" === data.code){
				$scope.gradeList = data.data;
			}else{
				alert(data.msg);
			}
	});

	$scope.findMajor = function(){

		if($scope.form.fk_grade == undefined || $scope.form.fk_grade == null){
			eventBusService.publish('modal.alert', {"title":"操作提示","content":"请先选择年级。"});
			return;
		}

		var type = "0";

		if($scope.form.type == "1"){
			$(".sjzy").attr("disabled",true);
			return;
		}else if($scope.form.type == "2"){
			$(".sjzy").attr("disabled",false);
			type = "'1'";
		}else{
			$(".sjzy").attr("disabled",false);
			type = "'1','2'";
		}

		httpService.post(app.urls.major_select,{"fk_grade":$scope.form.fk_grade,"type":type},function(data){
			if("0000" === data.code){
				$scope.majorList = data.data;
			}else{
				alert(data.msg);
			}
		});
	}

	$scope.saveForm = function(){
		if($scope.formCheck()){

			if($scope.form.type != "1"){
				if($scope.form.father_id == undefined || $scope.form.father_id == null){
					eventBusService.publish('modal.alert', {"title":"操作提示","content":"上级专业不能为空。"});
					return;
				}
			}else{
				$scope.form.father_id = "";
			}

			httpService.post(app.urls.major_insert,$scope.form,function(data){
				if("0000" === data.code){
					eventBusService.publish("content.page.reload", data);
					eventBusService.publish("modal.page.close", {});
	    		}else{
	    			alert(data.msg);
	    		}
			});
		}
	}
}}});